
<script>
$(function() {
	$( "#datepicker3" ).datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'yy/mm/dd',
		yearRange: '1950:2099'
	});
});
</script>

<script>
$(function() {
	$( "#datepicker4" ).datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'yy/mm/dd',
		yearRange: '1950:2099'
	});
});
</script>

<script>
$(function() {
	$( "#datepicker5" ).datepicker({
		changeMonth: true,
		changeYear: true,
		dateFormat: 'yy/mm/dd',
		yearRange: '1950:2099'
	});
});
</script>

<script>
function OnSubmitForm(){
	if(document.pressed == "Edit Resident"){
		document.residentform.action ="<?php echo base_url();?>index.php/residentController/loadEditResidentView/"+document.residentform.student_number.value;
		return true;
	}else if(document.pressed == "Delete Resident"){
		if(confirm("Are you sure you want to delete?")){
			document.residentform.action ="<?php echo base_url();?>index.php/residentController/deleteResident/";
			return true;
		}
	}else if(document.pressed == "Back to Main"){
		document.residentform.action ="<?php echo base_url();?>index.php/adminPageController/";
		return true;
	}
}
</script>

<script>
function OnSubmitForm2(){
	if(document.pressed == "Add Appliance"){
		if(document.applianceform.control_number.value!=""){
			document.applianceform.action ="<?php echo base_url();?>index.php/applianceController/addAppliance/"+document.applianceform.student_number.value;
			return true;
		}else{
			alert("Please enter control number!");
			return false;
		}
	}else if(document.pressed == "View Appliance"){
		if(<?php echo $appInfo->num_rows();?>==1){
			if(document.applianceform.choice.checked==true){
				document.applianceform.action ="<?php echo base_url();?>index.php/applianceController/loadViewApplianceView/"+document.applianceform.student_number.value+"/"+document.applianceform.choice.value;
				return true;
			}
		}else{
			for(i=0;i<<?php echo $appInfo->num_rows();?>;i++){
				if(document.applianceform.choice[i].checked==true){
					document.applianceform.action ="<?php echo base_url();?>index.php/applianceController/loadViewApplianceView/"+document.applianceform.student_number.value+"/"+document.applianceform.choice[i].value;
					return true;
				}
			}
		}
		alert("Please select appliance first!");
		return false;
	}else if(document.pressed == "Edit Appliance"){
		if(<?php echo $appInfo->num_rows();?>==1){
			if(document.applianceform.choice.checked==true){
				document.applianceform.action ="<?php echo base_url();?>index.php/applianceController/loadEditApplianceView/"+document.applianceform.student_number.value+"/"+document.applianceform.choice.value;
				return true;
			}
		}else{
			for(i=0;i<<?php echo $appInfo->num_rows();?>;i++){
				if(document.applianceform.choice[i].checked==true){
					document.applianceform.action ="<?php echo base_url();?>index.php/applianceController/loadEditApplianceView/"+document.applianceform.student_number.value+"/"+document.applianceform.choice[i].value;
					return true;
				}
			}
		}
		alert("Please select appliance first!");
		return false;
	}else if(document.pressed == "Delete Appliance"){
		if(<?php echo $appInfo->num_rows();?>==1){
			if(document.applianceform.choice.checked==true){
				if(confirm("Are you sure you want to delete?")){
					document.applianceform.action ="<?php echo base_url();?>index.php/applianceController/deleteAppliance/";
					return true;
				}else return false;
			}
		}else{
			for(i=0;i<<?php echo $appInfo->num_rows();?>;i++){
				if(document.applianceform.choice[i].checked==true){
					if(confirm("Are you sure you want to delete?")){
						document.applianceform.action ="<?php echo base_url();?>index.php/applianceController/deleteAppliance/";
						return true;
					}else return false;
				}
			}
		}
		alert("Please select appliance first!");
		return false;
	}else if(document.pressed == "Back to Main"){
		document.applianceform.action ="<?php echo base_url();?>index.php/adminPageController/";
		return true;
	}
}
</script>

<script>
function OnSubmitForm3(){
	if(document.pressed == "Add Payment"){
		if(document.paymentform.or_number.value!=""){
			document.paymentform.action ="<?php echo base_url();?>index.php/paymentController/addPayment/"+document.paymentform.student_number.value;
			return true;
		}else{
			alert("Please enter OR number!");
			return false;
		}
	}else if(document.pressed == "View Payment"){
		if(<?php echo $payInfo->num_rows();?>==1){
			if(document.paymentform.choice.checked==true){
				document.paymentform.action ="<?php echo base_url();?>index.php/paymentController/loadViewPaymentView/"+document.paymentform.student_number.value+"/"+document.paymentform.choice.value+"/"+document.paymentform.type_hidden.value;
				return true;
			}
		}else{
			for(i=0;i<<?php echo $payInfo->num_rows();?>;i++){
				if(document.paymentform.choice[i].checked==true){
					document.paymentform.action ="<?php echo base_url();?>index.php/paymentController/loadViewPaymentView/"+document.paymentform.student_number.value+"/"+document.paymentform.choice[i].value+"/"+document.paymentform.type_hidden[i].value;
					return true;
				}
			}
		}
		alert("Please select payment first!");
		return false;
	}else if(document.pressed == "Edit Payment"){
		if(<?php echo $payInfo->num_rows();?>==1){
			if(document.paymentform.choice.checked==true){
				document.paymentform.action ="<?php echo base_url();?>index.php/paymentController/loadEditPaymentView/"+document.paymentform.student_number.value+"/"+document.paymentform.choice.value+"/"+document.paymentform.type_hidden.value;
				return true;
			}
		}else{
			for(i=0;i<<?php echo $payInfo->num_rows();?>;i++){
				if(document.paymentform.choice[i].checked==true){
					document.paymentform.action ="<?php echo base_url();?>index.php/paymentController/loadEditPaymentView/"+document.paymentform.student_number.value+"/"+document.paymentform.choice[i].value+"/"+document.paymentform.type_hidden[i].value;
					return true;
				}
			}
		}
		alert("Please select payment first!");
		return false;
	}else if(document.pressed == "Delete Payment"){
		if(<?php echo $payInfo->num_rows();?>==1){
			if(document.paymentform.choice.checked==true){
				if(confirm("Are you sure you want to delete?")){
					document.paymentform.action ="<?php echo base_url();?>index.php/paymentController/deletePayment/"+document.paymentform.type_hidden.value;
					return true;
				}else return false;
			}
		}else{
			for(i=0;i<<?php echo $payInfo->num_rows();?>;i++){
				if(document.paymentform.choice[i].checked==true){
					if(confirm("Are you sure you want to delete?")){
						document.paymentform.action ="<?php echo base_url();?>index.php/paymentController/deletePayment/"+document.paymentform.type_hidden[i].value;
						return true;
					}else return false;
				}
			}
		}
		alert("Please select payment first!");
		return false;
	}else if(document.pressed == "Back to Main"){
		document.paymentform.action ="<?php echo base_url();?>index.php/adminPageController/";
		return true;
	}
}
</script>